	*------------------------------------------------------------------------------------------------------------%	
	* Figure 3: Distribution of large retailer gap across CZs in all, major and $15 VMWs
	*------------------------------------------------------------------------------------------------------------%	
		* Load event info
	use "$data/cb/events.dta", clear	
	drop if eventid==4
	
	* Drop overlapping events
	drop if min(months_since_last_policy, months_until_next_policy) <= 6
	
	levelsof eventid, local(exp)
	
	rename eventid trt_exp
	tempfile event_info
	save `event_info', replace
	
	clear
	foreach experiment in `exp' {
		append using "$data/cb/all_gap_measures_`experiment'_qtrly_wage_bill.dta"
		}		
		
	merge m:1 trt_exp using `event_info'

	* Gap measure
	sum T, d
	local T_mean=round(r(mean),.001)
	local T_std=round(r(sd),.001)
	hist T, percent bins(100) color("$dnwblue") xtitle("Gap") caption("Mean = `T_mean'" "St. Dev. = `T_std'", ring(0) pos(1))
	graph export "$figures_tables/fig3a_gap_distribution_cz_all.pdf", replace

	sum T if share_affected>.3, d
	local T_mean=round(r(mean),.001)
	local T_std=round(r(sd),.001)	
	hist T if share_affected>.3, percent bins(100) color("$dnwblue") xtitle("Gap") caption("Mean = `T_mean'" "St. Dev. = `T_std'", ring(0) pos(1))
	graph export "$figures_tables/fig3b_gap_distribution_cz_major.pdf", replace

	sum T if mw==15, d
	local T_mean=round(r(mean),.001)
	local T_std=round(r(sd),.001)	
	hist T if mw==15, percent bins(100) color("$dnwblue") xtitle("Gap") caption("Mean = `T_mean'" "St. Dev. = `T_std'", ring(0) pos(1))
	graph export "$figures_tables/fig3c_gap_distribution_cz_15.pdf", replace

	*------------------------------------------------------------------------------------------------------------%	
	* Figure F1, F2, and F3: Employment share distribution of large retailer across CZs in all, major and $15 VMWs
	*------------------------------------------------------------------------------------------------------------%	
	* Credit Bureau employment denominator
	sum employment_share, d
	local empshare_med =round(r(p50),.001)
	local empshare_mean = round(r(mean),.001)
	hist employment_share, percent bins(100) color("$dnwcrimson") xtitle("Employment Share of VMW firm in Credit Bureau Database") caption(Mean =`empshare_mean', ring(0) pos(1))
	graph export "$figures_tables/appendix/figf3a_empshare_distribution_cz_all.pdf", replace

	sum employment_share if share_affected>.3, d
	local empshare_med=round(r(p50),.001)
	local empshare_mean = round(r(mean),.001)
	hist employment_share if share_affected>.3, percent bins(100) color("$dnwcrimson") xtitle("Employment Share of VMW firm in Credit Bureau Database") caption(Mean =`empshare_mean', ring(0) pos(1))
	graph export "$figures_tables/appendix/figf3b_empshare_distribution_cz_major.pdf", replace

	sum employment_share if mw==15, d
	local empshare_med=round(r(p50),.001)
	local empshare_mean = round(r(mean),.001)
	hist employment_share if mw==15, percent bins(100) color("$dnwcrimson") xtitle("Employment Share of VMW firm in Credit Bureau Database") caption(Mean =`empshare_mean', ring(0) pos(1))
	graph export "$figures_tables/appendix/figf3c_empshare_distribution_cz_15.pdf", replace

	* QCEW employment denominator
	sum employment_share_q_all, d
	local empshare_med =round(r(p50),.001)
	local empshare_mean = round(r(mean),.001)
	hist employment_share_q_all, percent bins(100) color("$dnwbrown") xtitle("Employment Share of VMW firm") caption(Mean =`empshare_mean', ring(0) pos(1))
	graph export "$figures_tables/appendix/figf1a_empshare_q_distribution_cz_all.pdf", replace

	sum employment_share_q_all if share_affected>.3, d
	local empshare_med=round(r(p50),.001)
	local empshare_mean = round(r(mean),.001)
	hist employment_share_q_all if share_affected>.3, percent bins(100) color("$dnwbrown") xtitle("Employment Share of VMW firm") caption(Mean =`empshare_mean', ring(0) pos(1))
	graph export "$figures_tables/appendix/figf1b_empshare_q_distribution_cz_major.pdf", replace

	sum employment_share_q_all if mw==15, d
	local empshare_med=round(r(p50),.001)
	local empshare_mean = round(r(mean),.001)
	hist employment_share_q_all if mw==15, percent bins(100) color("$dnwbrown") xtitle("Employment Share of VMW firm") caption(Mean =`empshare_mean', ring(0) pos(1))
	graph export "$figures_tables/appendix/figf1c_empshare_q_distribution_cz_15.pdf", replace

	* QCEW retail employment denominator
	sum employment_share_q if employment_share_q, d
	replace employment_share_q = r(p99) if employment_share_q>r(p99)
	local empshare_med =round(r(p50),.001)
	local empshare_mean = round(r(mean),.001)
	hist employment_share_q, percent bins(100) color("$dnwbrown") xtitle("Retail Employment Share of VMW firm") caption(Mean =`empshare_mean', ring(0) pos(1))
	graph export "$figures_tables/appendix/figf2a_empshare_q_ret_distribution_cz_all.pdf", replace

	sum employment_share_q if share_affected>.3, d
	replace employment_share_q = r(p99) if employment_share_q>r(p99)
	local empshare_med=round(r(p50),.001)
	local empshare_mean = round(r(mean),.001)
	hist employment_share_q if share_affected>.3, percent bins(100) color("$dnwbrown") xtitle("Retail Employment Share of VMW firm") caption(Mean =`empshare_mean', ring(0) pos(1))
	graph export "$figures_tables/appendix/figf2b_empshare_q_ret_distribution_cz_major.pdf", replace

	sum employment_share_q if mw==15, d
	replace employment_share_q = r(p99) if employment_share_q>r(p99)
	local empshare_med=round(r(p50),.001)
	local empshare_mean = round(r(mean),.001)
	hist employment_share_q if mw==15, percent bins(100) color("$dnwbrown") xtitle("Retail Employment Share of VMW firm") caption(Mean =`empshare_mean', ring(0) pos(1))
	graph export "$figures_tables/appendix/figf2c_empshare_q_ret_distribution_cz_15.pdf", replace	
	
	*------------------------------------------------------------------------------------------------------------%	
	* Figure D4: Market gap distribution across CZs in all, major and $15 VMWs
	*------------------------------------------------------------------------------------------------------------%	

	* Super gap
	sum super_gap, d
	local super_gap_mean=round(r(mean),.001)
	local super_gap_std=round(r(sd),.001)	
	hist super_gap, percent bins(100) color("$dnwblue") xtitle("Market-level Gap") caption("Mean =`super_gap_mean'" "St. Dev. = `super_gap_std'", ring(0) pos(1))
	graph export "$figures_tables/appendix/figd4a_super_gap_distribution_cz_all.pdf", replace

	sum super_gap if share_affected>.3, d
	local super_gap_mean=round(r(mean),.001)
	local super_gap_std=round(r(sd),.001)	
	hist super_gap if share_affected>.3, percent bins(100) color("$dnwblue") xtitle("Market-level Gap") caption("Mean =`super_gap_mean'" "St. Dev. = `super_gap_std'", ring(0) pos(1))
	graph export "$figures_tables/appendix/figd4b_super_gap_distribution_cz_major.pdf", replace

	sum super_gap if mw==15, d
	local super_gap_mean=round(r(mean),.001)
	local super_gap_std=round(r(sd),.001)	
	hist super_gap if mw==15, percent bins(100) color("$dnwblue") xtitle("Market-level Gap") caption("Mean =`super_gap_mean'" "St. Dev. = `super_gap_std'", ring(0) pos(1))
	graph export "$figures_tables/appendix/figd4c_super_gap_distribution_cz_15.pdf", replace

	
* Table showing distribution of gap measure across experiments
	* Get rid of problematic QCEW months
	
	egen expid = group(trt_exp)	
	cap file close exposure_measures
	file open exposure_measures using "$figures_tables/appendix/tableb8_gap_distribution_by_experiment.txt", write replace
	file write exposure_measures "\begin{threeparttable} \begin{tabular}{ccccccc} Experiment & Mean & Std. Dev. & 25th  & Median  & 75th & 90th \\ \midrule " _n
	levelsof expid, local(exps)
	foreach exp in `exps' {
		qui sum T if expid==`exp',d
		local avgT: di %4.3f `r(mean)'
		local sdT: di %4.3f `r(sd)'
		local T25: di %4.3f `r(p25)'		
		local T50: di %4.3f `r(p50)' 
		local T75: di %4.3f `r(p75)' 
		local T90: di %4.3f `r(p90)'		
		file write exposure_measures "`exp' & `avgT' & `sdT' & `T25' & `T50' & `T75' & `T90' \\" _n
	}
	file write exposure_measures "\end{tabular}" "\begin{tablenotes}" _n
	file write exposure_measures "\end{tablenotes} \end{threeparttable}"
	file close exposure_measures
			
	*------------------------------------------------------------------------------------------------------------%	
	* Figure F4: Employment share distribution of non-policy firms across CZs in all, major and $15 VMWs
	*------------------------------------------------------------------------------------------------------------%	

	use "$data/cb/stacked_nonpolicy_employment_share.dta", clear

	* Credit bureau employment denominator
	sum np_emp_share, d
	local empshare_med =round(r(p50),.001)
	local empshare_mean = round(r(mean),.001)
	hist np_emp_share_q_all, percent bins(100) color("$dnwbrown") xtitle("Employment shares of non-policy firms") caption(Mean =`empshare_mean', ring(0) pos(1))
	graph export "$figures_tables/appendix/figf4a_np_empshare_distribution_cz_all.pdf", replace

	sum np_emp_share if share_affected>.3, d
	local empshare_med=round(r(p50),.001)
	local empshare_mean = round(r(mean),.001)
	hist np_emp_share_q_all if share_affected>.3, percent bins(100) color("$dnwbrown") xtitle("Employment shares of non-policy firms") caption(Mean =`empshare_mean', ring(0) pos(1))
	graph export "$figures_tables/appendix/figf4b_np_empshare_distribution_cz_major.pdf", replace

	sum np_emp_share if mw==15, d
	local empshare_med=round(r(p50),.001)
	local empshare_mean = round(r(mean),.001)
	hist np_emp_share_q_all if mw==15, percent bins(100) color("$dnwbrown") xtitle("Employment shares of non-policy firms") caption(Mean =`empshare_mean', ring(0) pos(1))
	graph export "$figures_tables/appendix/figf4c_np_empshare_distribution_cz_15.pdf", replace
		